//
//  HLRtcMoreView.m
//  YueYue
//
//  Created by hulu001 on 2023/6/27.
//

#import "HLRtcMoreView.h"

@interface HLRtcMoreView ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) QMUIButton *closeButton;

@property (nonatomic, strong) UIStackView *contentView;

@property (nonatomic, strong) UIView *bottomView;

@end

@implementation HLRtcMoreView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.backgroundColor = UIColorWhite;
    self.layer.cornerRadius = 20;
    self.titleLabel = [[UILabel alloc] qmui_initWithFont:UIFontMediumMake(15) textColor:HLTextColor1];
    _titleLabel.text = @"更多设置";
    [self addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20);
        make.centerX.mas_equalTo(0);
    }];
    
    self.closeButton = [[QMUIButton alloc] init];
    [_closeButton setImage:UIImageMake(@"rtc_more_close") forState:UIControlStateNormal];
    [self addSubview:_closeButton];
    [_closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(24);
        make.top.mas_equalTo(16);
        make.right.mas_equalTo(-12);
    }];
    
    self.contentView = [[UIStackView alloc] init];
    _contentView.axis = UILayoutConstraintAxisHorizontal;
    _contentView.distribution = UIStackViewDistributionEqualSpacing;
    _contentView.alignment = UIStackViewAlignmentCenter;
    [self addSubview:_contentView];
    [_contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.top.equalTo(_titleLabel.mas_bottom).offset(30);
        make.bottom.mas_equalTo(-(SafeAreaInsetsConstantForDeviceWithNotch.bottom + 30));
    }];
    
    self.muteButton = [[QMUIButton alloc] init];
    [_muteButton setTitle:@"麦克风" forState:UIControlStateNormal];
    [_muteButton setTitleColor:HLTextColor1 forState:UIControlStateNormal];
    [_muteButton setImage:UIImageMake(@"rtc_more_mute") forState:UIControlStateNormal];
    [_muteButton setImage:UIImageMake(@"rtc_more_mute_close") forState:UIControlStateSelected];
    [_muteButton.titleLabel setFont:UIFontMake(13)];
    [_muteButton setImagePosition:QMUIButtonImagePositionTop];
    [_muteButton setSpacingBetweenImageAndTitle:8];
    [_contentView addArrangedSubview:_muteButton];
    
    self.switchCameraButton = [[QMUIButton alloc] init];
    [_switchCameraButton setTitle:@"翻转" forState:UIControlStateNormal];
    [_switchCameraButton setTitleColor:HLTextColor1 forState:UIControlStateNormal];
    [_switchCameraButton setImage:UIImageMake(@"rtc_more_switch_camera") forState:UIControlStateNormal];
    [_switchCameraButton.titleLabel setFont:UIFontMake(13)];
    [_switchCameraButton setImagePosition:QMUIButtonImagePositionTop];
    [_switchCameraButton setSpacingBetweenImageAndTitle:8];
    [_contentView addArrangedSubview:_switchCameraButton];
    
    self.cameraButton = [[QMUIButton alloc] init];
    [_cameraButton setTitle:@"摄像头" forState:UIControlStateNormal];
    [_cameraButton setTitleColor:HLTextColor1 forState:UIControlStateNormal];
    [_cameraButton setImage:UIImageMake(@"rtc_more_camera") forState:UIControlStateNormal];
    [_cameraButton setImage:UIImageMake(@"rtc_more_camera_close") forState:UIControlStateSelected];
    [_cameraButton.titleLabel setFont:UIFontMake(13)];
    [_cameraButton setImagePosition:QMUIButtonImagePositionTop];
    [_cameraButton setSpacingBetweenImageAndTitle:8];
    [_contentView addArrangedSubview:_cameraButton];
    
    self.smallButton = [[QMUIButton alloc] init];
    [_smallButton setTitle:@"缩放" forState:UIControlStateNormal];
    [_smallButton setTitleColor:HLTextColor1 forState:UIControlStateNormal];
    [_smallButton setImage:UIImageMake(@"rtc_more_small") forState:UIControlStateNormal];
    [_smallButton.titleLabel setFont:UIFontMake(13)];
    [_smallButton setImagePosition:QMUIButtonImagePositionTop];
    [_smallButton setSpacingBetweenImageAndTitle:8];
    [_contentView addArrangedSubview:_smallButton];
}

+ (void)showWitContentView:(HLRtcMoreView *)contentView
{
    CGFloat height = 210;

    QMUIModalPresentationViewController *modalViewController = [[QMUIModalPresentationViewController alloc] init];
    modalViewController.contentViewMargins = UIEdgeInsetsMake(SCREEN_HEIGHT-height, 0, 0, 0);
    modalViewController.contentView = contentView;
    modalViewController.dimmingView.backgroundColor = UIColorClear;
    [modalViewController showWithAnimated:YES completion:nil];
    
    [contentView.closeButton setQmui_tapBlock:^(__kindof UIControl *sender) {
        [modalViewController hideWithAnimated:NO completion:nil];
    }];
    
}
@end
